﻿using Lanbt.Core.Entity.Dto;
using Lanbt.Core.Entity.Dto.quartz;
using Quartz;

namespace Lanbt.Core.Service.Quartz
{
    public interface IQuartzService
    {
        /// <summary>
        /// 是否存在重复任务
        /// </summary>
        /// <param name="oldJobKey"></param>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task<bool> ExistsJob(JobKey oldJobKey, JobKey jobKey);

        /// <summary>
        /// 获取Job详情
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task<ResultOutput<InsertJobInput>> GetJobDetail(JobKey jobKey);

        /// <summary>
        /// 获取全部任务
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PagesResultOutput<QueryJobDetailListOutput>> QueryJobDetailList(QueryJobDetailListInput input);

        /// <summary>
        /// 获取运行次数
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task<long> GetRunNumber(JobKey jobKey);

        /// <summary>
        /// 获取异常日志
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task<ResultOutput<string>> GetException(JobKey jobKey);

        /// <summary>
        /// 获取日志信列表
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task<ResultOutput<string>> QueryLogList(JobKey jobKey);

        /// <summary>
        /// 添加定时任务
        /// </summary>
        /// <param name="input"></param>
        /// <param name="runNumber">运行时间（修改时使用）</param>
        /// <returns></returns>
        Task InsertJob(InsertJobInput input, long? runNumber = null);

        /// <summary>
        /// 暂停任务
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task PauseJob(JobKey jobKey);

        /// <summary>
        /// 恢复任务
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task ResumeJob(JobKey jobKey);

        /// <summary>
        /// 删除任务
        /// </summary>
        /// <param name="jobKey"></param>
        /// <returns></returns>
        Task DeleteJob(JobKey jobKey);
    }
}
